package com.findme.securitydb.utils;

import java.util.ArrayList;

/**
 * @Description 字符串相关工具类
 * @Author find me
 * @Createtime 2020/3/27 1:19
 * @ClassName MeStringUtils
 */
public class MeStringUtils {


    public static String stringCollation(String content) {
        if (content != null && !("").equals(content)) {
            //调用API方法按照逗号分隔字符串
            String[] ary = content.split(",|，");
            ArrayList<String> strings = new ArrayList<>();
            for (String item : ary) {
                if (!("").equals(item)) {

                    strings.add(item);
                }
            }

            StringBuffer str2 = new StringBuffer();
            for (int i = 0; i < strings.size(); i++) {
                //用append()方法拼接
                if (i == strings.size() - 1) {
                    str2.append(strings.get(i));
                } else {
                    str2.append(strings.get(i) + ",");
                }
            }
            System.out.println(str2);
            return str2.toString();
        } else {
            return content;
        }


    }
}

